﻿namespace homewizard
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.IO;
    using System.ServiceModel;
    using System.ServiceModel.Web;
    using System.Text;
    using System.Web;
    using System.Web.Script.Serialization;

    public class Homewizardservice : IHomewizardservice
    {
        #region [Feedback,Ideas,Tasks,Tips,verifyPromoCode]

        public Stream getFeedBack(string feedback)
        {
            string str4;
            string str2 = "";
            str2 = new login { operation = 13, feedback = feedback }.InsertFeedBack();
            login login2 = new login();
            string str3 = Convert.ToString(OperationContext.Current.RequestContext.RequestMessage.Headers.To);
            login2.WebServiceName = "getFeedBack";
            login2.DataForService = str3;
            using (StreamReader reader = new StreamReader(this.WriteJson(new { status = str2 }), Encoding.Default))
            {
                str4 = reader.ReadToEnd();
            }
            login2.DataRecived = str4;
            login2.webserviceListInsert();
            return this.WriteJson(new { status = str2 });


        }

        public Stream getIdeas(Stream myfile)
        {
            string str11;
            int num6;
            int num7;
            string str13;
            string str = "";
            string str2 = "";
            string str3 = "";
            string str4 = "";
            string str5 = "";
            string str6 = "";
            string str7 = "";
            string str8 = "";
            string[] strArray = new string[] { 
                "idea_code", "display_icon_code", "idea_title", "idea_content", "idea_timing", "idea_score", "idea_priority", "idea_type", "idea_benefit_content", "idea_energy_savings_score", "idea_energy_savings_content", "idea_cost_score", "idea_more_info_link", "idea_knowledge_level", "TGMS", "benefits_str", 
                "idea_excluded_features"
             };
            StreamReader reader = new StreamReader(myfile, true);
            string[] strArray2 = HttpUtility.UrlDecode(reader.ReadToEnd()).Split(new char[] { '/' });
            int num2 = 7;
            string str10 = "no";
            login login = new login();
            string[] strArray3 = strArray2[0].Split(new char[] { '=' });
            login.dwell_priority_kl_loc = strArray3[1];
            str = strArray3[1];
            strArray3 = strArray2[1].Split(new char[] { '=' });
            login.feature_string = strArray3[1];
            str2 = strArray3[1];
            strArray3 = strArray2[2].Split(new char[] { '=' });
            login.ps_goal_string = strArray3[1];
            str3 = strArray3[1];
            strArray3 = strArray2[3].Split(new char[] { '=' });
            if (strArray3[1] == "(null)")
            {
                login.turn_offs = "no";
            }
            else
            {
                login.turn_offs = strArray3[1];
            }
            str4 = strArray3[1];
            strArray3 = strArray2[4].Split(new char[] { '=' });
            login.startmonth = strArray3[1];
            str5 = strArray3[1];
            strArray3 = strArray2[5].Split(new char[] { '=' });
            login.startyear = strArray3[1];
            str6 = strArray3[1];
            strArray3 = strArray2[6].Split(new char[] { '=' });
            login.requestedmonth = strArray3[1];
            str7 = strArray3[1];
            strArray3 = strArray2[7].Split(new char[] { '=' });
            login.requestedyear = strArray3[1];
            str8 = strArray3[1];
            DataSet set = login.ideadata();
            bool flag = false;
            int index = -1;
            Dictionary<string, string>[] dictionaryArray = new Dictionary<string, string>[num2];
            if ((set.Tables.Count > 0) && (set.Tables[0].Rows.Count < num2))
            {
                str10 = "yes";
                for (num6 = 0; num6 < set.Tables[0].Rows.Count; num6++)
                {
                    flag = false;
                    str11 = set.Tables[0].Rows[num6]["idea_excluded_features"].ToString().Trim();
                    if (str11.Length > 0)
                    {
                        flag = this.isInclude(login.feature_string, str11);
                    }
                    if (!flag)
                    {
                        index++;
                        dictionaryArray[index] = new Dictionary<string, string>();
                        num7 = 0;
                        while (num7 < strArray.Length)
                        {
                            dictionaryArray[index].Add(strArray[num7], set.Tables[0].Rows[num6][strArray[num7]].ToString());
                            num7++;
                        }
                    }
                }
                set = login.tipdata();
            }
            else
            {
                index = 0;
            }
            if ((set.Tables[0].Rows.Count > 0) && (index < num2))
            {
                for (num6 = 0; num6 < set.Tables[0].Rows.Count; num6++)
                {
                    while ((index < num2) && (num6 < set.Tables[0].Rows.Count))
                    {
                        flag = false;
                        str11 = set.Tables[0].Rows[num6]["idea_excluded_features"].ToString().Trim();
                        if (str11.Length > 0)
                        {
                            flag = this.isInclude(login.feature_string, str11);
                        }
                        if (!flag)
                        {
                            dictionaryArray[index] = new Dictionary<string, string>();
                            num7 = 0;
                            while (num7 < strArray.Length)
                            {
                                dictionaryArray[index].Add(strArray[num7], set.Tables[0].Rows[num6][strArray[num7]].ToString());
                                num7++;
                            }
                            index++;
                            num6++;
                        }
                    }
                }
            }
            else
            {
                dictionaryArray = new Dictionary<string, string>[] { new Dictionary<string, string>() };
                for (num7 = 0; num7 < strArray.Length; num7++)
                {
                    dictionaryArray[0].Add(strArray[num7], "No Information");
                }
            }
            login login2 = new login();
            string str12 = Convert.ToString(OperationContext.Current.RequestContext.RequestMessage.Headers.To);
            login2.WebServiceName = "getIdeas";
            if (str4 == "(null)")
            {
                str4 = "no";
                login2.DataForService = str12 + "/DwellingInfo=" + str + "/Featurestring=" + str2 + "/GoalString=" + str3 + "/TurnOffsString=" + str4 + "/StartMonth=" + str5 + "/StartYear=" + str6 + "/RequestedMonth=" + str7 + "/RequestedYear=" + str8;
            }
            else
            {
                login2.DataForService = str12 + "/DwellingInfo=" + str + "/Featurestring=" + str2 + "/GoalString=" + str3 + "/TurnOffsString=" + str4 + "/StartMonth=" + str5 + "/StartYear=" + str6 + "/RequestedMonth=" + str7 + "/RequestedYear=" + str8;
            }
            using (StreamReader reader2 = new StreamReader(this.WriteJson(new { dictionary = dictionaryArray }), Encoding.Default))
            {
                str13 = reader2.ReadToEnd();
            }
            login2.DataRecived = str13;
            login2.webserviceListInsert(); //commented just for now to testing only, remove after that.
            return this.WriteJson(new { countdata = str10, dictionary = dictionaryArray });
        }

        public Stream getIdeas1(Stream myfile)
        {
            int num4;
            int num5;
            string str12;
            string str = "";
            string str2 = "";
            string str3 = "";
            string str4 = "";
            string str5 = "";
            string str6 = "";
            string str7 = "";
            string str8 = "";
            string[] strArray = new string[] { "idea_code", "display_icon_code", "idea_title", "idea_content", "idea_timing", "idea_score", "idea_priority", "idea_type", "idea_benefit_content", "idea_energy_savings_score", "idea_energy_savings_content", "idea_cost_score", "idea_more_info_link", "idea_knowledge_level", "TGMS", "benefits_str" };
            StreamReader reader = new StreamReader(myfile, true);
            string[] strArray2 = HttpUtility.UrlDecode(reader.ReadToEnd()).Split(new char[] { '/' });
            int num = 0;
            int num2 = 7;
            int num3 = 0;
            string str10 = "no";
            login login = new login();
            string[] strArray3 = strArray2[0].Split(new char[] { '=' });
            login.dwell_priority_kl_loc = strArray3[1];
            str = strArray3[1];
            strArray3 = strArray2[1].Split(new char[] { '=' });
            login.feature_string = strArray3[1];
            str2 = strArray3[1];
            strArray3 = strArray2[2].Split(new char[] { '=' });
            login.ps_goal_string = strArray3[1];
            str3 = strArray3[1];
            strArray3 = strArray2[3].Split(new char[] { '=' });
            if (strArray3[1] == "(null)")
            {
                login.turn_offs = "no";
            }
            else
            {
                login.turn_offs = strArray3[1];
            }
            str4 = strArray3[1];
            strArray3 = strArray2[4].Split(new char[] { '=' });
            login.startmonth = strArray3[1];
            str5 = strArray3[1];
            strArray3 = strArray2[5].Split(new char[] { '=' });
            login.startyear = strArray3[1];
            str6 = strArray3[1];
            strArray3 = strArray2[6].Split(new char[] { '=' });
            login.requestedmonth = strArray3[1];
            str7 = strArray3[1];
            strArray3 = strArray2[7].Split(new char[] { '=' });
            login.requestedyear = strArray3[1];
            str8 = strArray3[1];
            DataSet set = login.ideadata();
            Dictionary<string, string>[] dictionaryArray = new Dictionary<string, string>[num2];
            if ((set.Tables.Count > 0) && (set.Tables[0].Rows.Count < num2))
            {
                str10 = "yes";
                for (num4 = 0; num4 < set.Tables[0].Rows.Count; num4++)
                {
                    dictionaryArray[num4] = new Dictionary<string, string>();
                    num5 = 0;
                    while (num5 < strArray.Length)
                    {
                        dictionaryArray[num4].Add(strArray[num5], set.Tables[0].Rows[num4][strArray[num5]].ToString());
                        num5++;
                    }
                    num3 = num4;
                }
                num = num2 - set.Tables[0].Rows.Count;
                set = login.tipdata();
            }
            else
            {
                num3 = 0;
                num = num2;
            }
            if ((set.Tables[0].Rows.Count > 0) && (num3 < num))
            {
                for (num4 = num3; num4 < num; num4++)
                {
                    dictionaryArray[num4] = new Dictionary<string, string>();
                    num5 = 0;
                    while (num5 < strArray.Length)
                    {
                        dictionaryArray[num4].Add(strArray[num5], set.Tables[0].Rows[num4][strArray[num5]].ToString());
                        num5++;
                    }
                }
            }
            else
            {
                dictionaryArray = new Dictionary<string, string>[] { new Dictionary<string, string>() };
                for (num5 = 0; num5 < strArray.Length; num5++)
                {
                    dictionaryArray[0].Add(strArray[num5], "No Information");
                }
            }
            login login2 = new login();
            string str11 = Convert.ToString(OperationContext.Current.RequestContext.RequestMessage.Headers.To);
            login2.WebServiceName = "getIdeas";
            if (str4 == "(null)")
            {
                str4 = "no";
                login2.DataForService = str11 + "/DwellingInfo=" + str + "/Featurestring=" + str2 + "/GoalString=" + str3 + "/TurnOffsString=" + str4 + "/StartMonth=" + str5 + "/StartYear=" + str6 + "/RequestedMonth=" + str7 + "/RequestedYear=" + str8;
            }
            else
            {
                login2.DataForService = str11 + "/DwellingInfo=" + str + "/Featurestring=" + str2 + "/GoalString=" + str3 + "/TurnOffsString=" + str4 + "/StartMonth=" + str5 + "/StartYear=" + str6 + "/RequestedMonth=" + str7 + "/RequestedYear=" + str8;
            }
            using (StreamReader reader2 = new StreamReader(this.WriteJson(new { dictionary = dictionaryArray }), Encoding.Default))
            {
                str12 = reader2.ReadToEnd();
            }
            login2.DataRecived = str12;
            login2.webserviceListInsert();
            return this.WriteJson(new { countdata = str10, dictionary = dictionaryArray });
        }

        public Stream getRoutineTask(Stream myfile)
        {
            Dictionary<string, string>[] dictionaryArray;
            int num5;
            string str14;
            string str = "";
            string str2 = "";
            string str3 = "";
            string str4 = "";
            string str5 = "";
            string str6 = "";
            string str7 = "";
            string str8 = "";
            string[] strArray = new string[] { 
                "task_code", "display_icon_code", "rc_task_title", "rc_task_content", "rc_rec_timing", "rc_priority", "rc_type", "rc_benefit_content", "rc_energy_savings_score", "rc_energy_savings_content", "rc_cost_score", "rc_cost_content", "rc_more_info_link", "rc_knowledge_level", "rc_cycle_timing", "rc_timing_months", 
                "TGMS", "benefits_str"
             };
            StreamReader reader = new StreamReader(myfile, true);
            string[] strArray2 = HttpUtility.UrlDecode(reader.ReadToEnd()).Split(new char[] { '/' });
            login login = new login();
            string[] strArray3 = strArray2[0].Split(new char[] { '=' });
            login.dwell_priority_kl_loc = strArray3[1];
            str = strArray3[1];
            strArray3 = strArray2[1].Split(new char[] { '=' });
            login.feature_string = strArray3[1];
            str2 = strArray3[1];
            strArray3 = strArray2[2].Split(new char[] { '=' });
            login.ps_goal_string = strArray3[1];
            str3 = strArray3[1];
            strArray3 = strArray2[3].Split(new char[] { '=' });
            if (strArray3[1] == "(null)")
            {
                login.turn_offs = "no";
            }
            else
            {
                login.turn_offs = strArray3[1];
            }
            str4 = strArray3[1];
            strArray3 = strArray2[4].Split(new char[] { '=' });
            login.startmonth = strArray3[1];
            str5 = strArray3[1];
            strArray3 = strArray2[5].Split(new char[] { '=' });
            login.startyear = strArray3[1];
            str6 = strArray3[1];
            strArray3 = strArray2[6].Split(new char[] { '=' });
            login.requestedmonth = strArray3[1];
            str7 = strArray3[1];
            strArray3 = strArray2[7].Split(new char[] { '=' });
            login.requestedyear = strArray3[1];
            str8 = strArray3[1];
            DataSet set = login.task();
            string str10 = "no";
            bool flag = false;
            int index = 0;
            string str12 = "";
            if ((set.Tables.Count > 0) && (set.Tables[0].Rows.Count > 0))
            {
                dictionaryArray = new Dictionary<string, string>[set.Tables[0].Rows.Count];
                for (int i = 0; i < set.Tables[0].Rows.Count; i++)
                {
                    int num4 = 0;
                    flag = false;
                    str12 = set.Tables[0].Rows[i]["rc_excluded_features"].ToString().Trim();
                    if (str12.Length > 0)
                    {
                        string[] strArray4 = str12.Split(new char[] { ',' });
                        while ((num4 < strArray4.Length) && !flag)
                        {
                            if (str2.IndexOf(strArray4[num4].Trim()) > 0)
                            {
                                flag = true;
                            }
                            else
                            {
                                num4++;
                            }
                        }
                    }
                    if (!flag)
                    {
                        dictionaryArray[index] = new Dictionary<string, string>();
                        num5 = 0;
                        while (num5 < strArray.Length)
                        {
                            dictionaryArray[index].Add(strArray[num5], set.Tables[0].Rows[i][strArray[num5]].ToString());
                            num5++;
                        }
                        index++;
                    }
                }
            }
            else
            {
                dictionaryArray = new Dictionary<string, string>[] { new Dictionary<string, string>() };
                for (num5 = 0; num5 < strArray.Length; num5++)
                {
                    dictionaryArray[0].Add(strArray[num5], "No Information");
                }
            }
            login login2 = new login();
            string str13 = Convert.ToString(OperationContext.Current.RequestContext.RequestMessage.Headers.To);
            login2.WebServiceName = "getRoutineTask";
            login2.DataForService = str13 + "/DwellingInfo=" + str + "/Featurestring=" + str2 + "/GoalString=" + str3 + "/TurnOffsString=" + str4 + "/StartMonth=" + str5 + "/StartYear=" + str6 + "/RequestedMonth=" + str7 + "/RequestedYear=" + str8;
            using (StreamReader reader2 = new StreamReader(this.WriteJson(new { dictionary = dictionaryArray }), Encoding.Default))
            {
                str14 = reader2.ReadToEnd();
            }
            login2.DataRecived = str14;
            login2.webserviceListInsert();
            return this.WriteJson(new { countdata = str10, dictionary = dictionaryArray });
        }

        public Stream getRoutineTask1(Stream myfile)
        {
            Dictionary<string, string>[] dictionaryArray;
            int num2;
            string str12;
            string str = "";
            string str2 = "";
            string str3 = "";
            string str4 = "";
            string str5 = "";
            string str6 = "";
            string str7 = "";
            string str8 = "";
            string[] strArray = new string[] { 
                "task_code", "display_icon_code", "rc_task_title", "rc_task_content", "rc_rec_timing", "rc_priority", "rc_type", "rc_benefit_content", "rc_energy_savings_score", "rc_energy_savings_content", "rc_cost_score", "rc_cost_content", "rc_more_info_link", "rc_knowledge_level", "rc_cycle_timing", "rc_timing_months", 
                "TGMS", "benefits_str"
             };
            StreamReader reader = new StreamReader(myfile, true);
            string[] strArray2 = HttpUtility.UrlDecode(reader.ReadToEnd()).Split(new char[] { '/' });
            login login = new login();
            string[] strArray3 = strArray2[0].Split(new char[] { '=' });
            login.dwell_priority_kl_loc = strArray3[1];
            str = strArray3[1];
            strArray3 = strArray2[1].Split(new char[] { '=' });
            login.feature_string = strArray3[1];
            str2 = strArray3[1];
            strArray3 = strArray2[2].Split(new char[] { '=' });
            login.ps_goal_string = strArray3[1];
            str3 = strArray3[1];
            strArray3 = strArray2[3].Split(new char[] { '=' });
            if (strArray3[1] == "(null)")
            {
                login.turn_offs = "no";
            }
            else
            {
                login.turn_offs = strArray3[1];
            }
            str4 = strArray3[1];
            strArray3 = strArray2[4].Split(new char[] { '=' });
            login.startmonth = strArray3[1];
            str5 = strArray3[1];
            strArray3 = strArray2[5].Split(new char[] { '=' });
            login.startyear = strArray3[1];
            str6 = strArray3[1];
            strArray3 = strArray2[6].Split(new char[] { '=' });
            login.requestedmonth = strArray3[1];
            str7 = strArray3[1];
            strArray3 = strArray2[7].Split(new char[] { '=' });
            login.requestedyear = strArray3[1];
            str8 = strArray3[1];
            DataSet set = login.task();
            string str10 = "no";
            if ((set.Tables.Count > 0) && (set.Tables[0].Rows.Count > 0))
            {
                dictionaryArray = new Dictionary<string, string>[set.Tables[0].Rows.Count];
                for (int i = 0; i < set.Tables[0].Rows.Count; i++)
                {
                    dictionaryArray[i] = new Dictionary<string, string>();
                    num2 = 0;
                    while (num2 < strArray.Length)
                    {
                        dictionaryArray[i].Add(strArray[num2], set.Tables[0].Rows[i][strArray[num2]].ToString());
                        num2++;
                    }
                }
            }
            else
            {
                dictionaryArray = new Dictionary<string, string>[] { new Dictionary<string, string>() };
                for (num2 = 0; num2 < strArray.Length; num2++)
                {
                    dictionaryArray[0].Add(strArray[num2], "No Information");
                }
            }
            login login2 = new login();
            string str11 = Convert.ToString(OperationContext.Current.RequestContext.RequestMessage.Headers.To);
            login2.WebServiceName = "getRoutineTask";
            login2.DataForService = str11 + "/DwellingInfo=" + str + "/Featurestring=" + str2 + "/GoalString=" + str3 + "/TurnOffsString=" + str4 + "/StartMonth=" + str5 + "/StartYear=" + str6 + "/RequestedMonth=" + str7 + "/RequestedYear=" + str8;
            using (StreamReader reader2 = new StreamReader(this.WriteJson(new { dictionary = dictionaryArray }), Encoding.Default))
            {
                str12 = reader2.ReadToEnd();
            }
            login2.DataRecived = str12;
            login2.webserviceListInsert();
            return this.WriteJson(new { countdata = str10, dictionary = dictionaryArray });
        }

        public Stream getTips(Stream myfile)
        {
            string str11;
            int num5;
            int num6;
            string str13;
            string str = "";
            string paramFeatureString = "";
            string str3 = "";
            string str4 = "";
            string str5 = "";
            string str6 = "";
            string str7 = "";
            string str8 = "";
            string[] strArray = new string[] { 
                "tip_code", "display_icon_code", "tip_title", "tip_content", "tip_timing", "tip_priority", "tip_type", "tip_benefit_content", "tip_energy_savings_score", "tip_energy_savings_content", "tip_cost_score", "tip_cost_content", "tip_more_info_link", "tip_knowledge_level", "tip_score", "TGMS", 
                "benefits_str"
             };
            StreamReader reader = new StreamReader(myfile, true);
            string[] strArray2 = HttpUtility.UrlDecode(reader.ReadToEnd()).Split(new char[] { '/' });
            int num2 = 7;
            string str10 = "no";
            login login = new login();
            string[] strArray3 = strArray2[0].Split(new char[] { '=' });
            login.dwell_priority_kl_loc = strArray3[1];
            str = strArray3[1];
            strArray3 = strArray2[1].Split(new char[] { '=' });
            login.feature_string = strArray3[1];
            paramFeatureString = strArray3[1];
            strArray3 = strArray2[2].Split(new char[] { '=' });
            login.ps_goal_string = strArray3[1];
            str3 = strArray3[1];
            strArray3 = strArray2[3].Split(new char[] { '=' });
            if (strArray3[1] == "(null)")
            {
                login.turn_offs = "no";
            }
            else
            {
                login.turn_offs = strArray3[1];
            }
            str4 = strArray3[1];
            strArray3 = strArray2[4].Split(new char[] { '=' });
            login.startmonth = strArray3[1];
            str5 = strArray3[1];
            strArray3 = strArray2[5].Split(new char[] { '=' });
            login.startyear = strArray3[1];
            str6 = strArray3[1];
            strArray3 = strArray2[6].Split(new char[] { '=' });
            login.requestedmonth = strArray3[1];
            str7 = strArray3[1];
            strArray3 = strArray2[7].Split(new char[] { '=' });
            login.requestedyear = strArray3[1];
            str8 = strArray3[1];
            DataSet set = new DataSet();
            set = login.tipdata();
            bool flag = false;
            int index = -1;
            Dictionary<string, string>[] dictionaryArray = new Dictionary<string, string>[num2];
            if ((set.Tables.Count > 0) && (set.Tables[0].Rows.Count < num2))
            {
                str10 = "yes";
                for (num5 = 0; num5 < set.Tables[0].Rows.Count; num5++)
                {
                    flag = false;
                    str11 = set.Tables[0].Rows[num5]["idea_excluded_features"].ToString().Trim();
                    if (str11.Length > 0)
                    {
                        flag = this.isInclude(paramFeatureString, str11);
                    }
                    if (!flag)
                    {
                        index++;
                        dictionaryArray[index] = new Dictionary<string, string>();
                        num6 = 0;
                        while (num6 < strArray.Length)
                        {
                            dictionaryArray[num5].Add(strArray[num6], set.Tables[0].Rows[num5][strArray[num6]].ToString());
                            num6++;
                        }
                    }
                }
                set = login.tipdata();
            }
            else
            {
                index = 0;
            }
            if ((set.Tables[0].Rows.Count > 0) && (index < num2))
            {
                num5 = 0;
                while ((index < num2) && (num5 < set.Tables[0].Rows.Count))
                {
                    flag = false;
                    str11 = set.Tables[0].Rows[num5]["tip_excluded_features"].ToString().Trim();
                    if (str11.Length > 0)
                    {
                        flag = this.isInclude(paramFeatureString, str11);
                    }
                    if (!flag)
                    {
                        dictionaryArray[index] = new Dictionary<string, string>();
                        num6 = 0;
                        while (num6 < strArray.Length)
                        {
                            dictionaryArray[index].Add(strArray[num6], set.Tables[0].Rows[num5][strArray[num6]].ToString().Trim());
                            num6++;
                        }
                        index++;
                        num5++;
                    }
                }
            }
            else
            {
                dictionaryArray = new Dictionary<string, string>[] { new Dictionary<string, string>() };
                for (num6 = 0; num6 < strArray.Length; num6++)
                {
                    dictionaryArray[0].Add(strArray[num6], "No Information");
                }
            }
            login login2 = new login();
            string str12 = Convert.ToString(OperationContext.Current.RequestContext.RequestMessage.Headers.To);
            login2.WebServiceName = "monthlytips";
            if (str4 == "(null)")
            {
                str4 = "no";
                login2.DataForService = str12 + "/DwellingInfo=" + str + "/Featurestring=" + paramFeatureString + "/GoalString=" + str3 + "/TurnOffsString=" + str4 + "/StartMonth=" + str5 + "/StartYear=" + str6 + "/RequestedMonth=" + str7 + "/RequestedYear=" + str8;
            }
            else
            {
                login2.DataForService = str12 + "/DwellingInfo=" + str + "/Featurestring=" + paramFeatureString + "/GoalString=" + str3 + "/TurnOffsString=" + str4 + "/StartMonth=" + str5 + "/StartYear=" + str6 + "/RequestedMonth=" + str7 + "/RequestedYear=" + str8;
            }
            using (StreamReader reader2 = new StreamReader(this.WriteJson(new { dictionary = dictionaryArray }), Encoding.Default))
            {
                str13 = reader2.ReadToEnd();
            }
            login2.DataRecived = str13;
            login2.webserviceListInsert();
            return this.WriteJson(new { countdata = str10, dictionary = dictionaryArray });
        }

        public Stream getTips1(Stream myfile)
        {
            int num4;
            int num5;
            string str12;
            string str = "";
            string str2 = "";
            string str3 = "";
            string str4 = "";
            string str5 = "";
            string str6 = "";
            string str7 = "";
            string str8 = "";
            string[] strArray = new string[] { 
                "tip_code", "display_icon_code", "tip_title", "tip_content", "tip_timing", "tip_priority", "tip_type", "tip_benefit_content", "tip_energy_savings_score", "tip_energy_savings_content", "tip_cost_score", "tip_cost_content", "tip_more_info_link", "tip_knowledge_level", "tip_score", "TGMS", 
                "benefits_str"
             };
            StreamReader reader = new StreamReader(myfile, true);
            string[] strArray2 = HttpUtility.UrlDecode(reader.ReadToEnd()).Split(new char[] { '/' });
            int num = 0;
            int num2 = 7;
            int num3 = 0;
            string str10 = "no";
            login login = new login();
            string[] strArray3 = strArray2[0].Split(new char[] { '=' });
            login.dwell_priority_kl_loc = strArray3[1];
            str = strArray3[1];
            strArray3 = strArray2[1].Split(new char[] { '=' });
            login.feature_string = strArray3[1];
            str2 = strArray3[1];
            strArray3 = strArray2[2].Split(new char[] { '=' });
            login.ps_goal_string = strArray3[1];
            str3 = strArray3[1];
            strArray3 = strArray2[3].Split(new char[] { '=' });
            if (strArray3[1] == "(null)")
            {
                login.turn_offs = "no";
            }
            else
            {
                login.turn_offs = strArray3[1];
            }
            strArray3 = strArray2[4].Split(new char[] { '=' });
            login.startmonth = strArray3[1];
            str5 = strArray3[1];
            strArray3 = strArray2[5].Split(new char[] { '=' });
            login.startyear = strArray3[1];
            str6 = strArray3[1];
            strArray3 = strArray2[6].Split(new char[] { '=' });
            login.requestedmonth = strArray3[1];
            str7 = strArray3[1];
            strArray3 = strArray2[7].Split(new char[] { '=' });
            login.requestedyear = strArray3[1];
            str8 = strArray3[1];
            DataSet set = new DataSet();
            set = login.tipdata();
            Dictionary<string, string>[] dictionaryArray = new Dictionary<string, string>[num2];
            if ((set.Tables.Count > 0) && (set.Tables[0].Rows.Count < num2))
            {
                str10 = "yes";
                for (num4 = 0; num4 < set.Tables[0].Rows.Count; num4++)
                {
                    dictionaryArray[num4] = new Dictionary<string, string>();
                    num5 = 0;
                    while (num5 < strArray.Length)
                    {
                        dictionaryArray[num4].Add(strArray[num5], set.Tables[0].Rows[num4][strArray[num5]].ToString());
                        num5++;
                    }
                    num3 = num4;
                }
                num = num2 - set.Tables[0].Rows.Count;
                set = login.tipdata();
            }
            else
            {
                num3 = 0;
                num = num2;
            }
            if ((set.Tables[0].Rows.Count > 0) && (num3 < num))
            {
                for (num4 = num3; num4 < num; num4++)
                {
                    dictionaryArray[num4] = new Dictionary<string, string>();
                    num5 = 0;
                    while (num5 < strArray.Length)
                    {
                        dictionaryArray[num4].Add(strArray[num5], set.Tables[0].Rows[num4][strArray[num5]].ToString());
                        num5++;
                    }
                }
            }
            else
            {
                dictionaryArray = new Dictionary<string, string>[] { new Dictionary<string, string>() };
                for (num5 = 0; num5 < strArray.Length; num5++)
                {
                    dictionaryArray[0].Add(strArray[num5], "No Information");
                }
            }
            login login2 = new login();
            string str11 = Convert.ToString(OperationContext.Current.RequestContext.RequestMessage.Headers.To);
            login2.WebServiceName = "getTips";
            if (str4 == "(null)")
            {
                str4 = "no";
                login2.DataForService = str11 + "/DwellingInfo=" + str + "/Featurestring=" + str2 + "/GoalString=" + str3 + "/TurnOffsString=" + str4 + "/StartMonth=" + str5 + "/StartYear=" + str6 + "/RequestedMonth=" + str7 + "/RequestedYear=" + str8;
            }
            else
            {
                login2.DataForService = str11 + "/DwellingInfo=" + str + "/Featurestring=" + str2 + "/GoalString=" + str3 + "/TurnOffsString=" + str4 + "/StartMonth=" + str5 + "/StartYear=" + str6 + "/RequestedMonth=" + str7 + "/RequestedYear=" + str8;
            }
            using (StreamReader reader2 = new StreamReader(this.WriteJson(new { dictionary = dictionaryArray }), Encoding.Default))
            {
                str12 = reader2.ReadToEnd();
            }
            login2.DataRecived = str12;
            login2.webserviceListInsert();
            return this.WriteJson(new { countdata = str10, dictionary = dictionaryArray });
        }

        public bool isInclude(string paramFeatureString, string paramExclusionFeatures)
        {
            string str = "";
            bool flag = false;
            bool flag2 = false;
            int index = 0;
            string[] strArray = str.Split(new char[] { ',' });
            while ((index < strArray.Length) && !flag2)
            {
                if (paramFeatureString.IndexOf(strArray[index].Trim()) > 0)
                {
                    flag = true;
                }
                else
                {
                    index++;
                }
            }
            return flag;
        }

        public Stream verifyPromoCode(Stream myfile)
        {
            Dictionary<string, string> dictionary;
            login login2;
            string str3;
            string str4;
            StreamReader reader = new StreamReader(myfile, true);
            string str = HttpUtility.UrlDecode(reader.ReadToEnd()).Split(new char[] { '=' })[1];
            login login = new login();
            string str2 = "";
            login.promocode = str;
            DataSet set = login.promologin();
            if ((set.Tables.Count > 0) && (set.Tables[0].Rows.Count > 0))
            {
                str2 = "success";
                dictionary = new Dictionary<string, string>();
                foreach (DataRow row in set.Tables[0].Rows)
                {
                    if (row["sponsor_status"].ToString() == "A")
                    {
                        if (row["iname_line"].ToString() != "")
                        {
                            dictionary.Add("iname_line", row["iname_line"].ToString());
                        }
                        else
                        {
                            dictionary.Add("iname_line", "No Information");
                        }
                        if (row["icompany_name"].ToString() != "")
                        {
                            dictionary.Add("icompany_name", row["icompany_name"].ToString());
                        }
                        else
                        {
                            dictionary.Add("icompany_name", "No Information");
                        }
                        if (row["iemail_address"].ToString() != "")
                        {
                            dictionary.Add("iemail_address", row["iemail_address"].ToString());
                        }
                        else
                        {
                            dictionary.Add("iemail_address", "No Information");
                        }
                        if (row["iphone_number"].ToString() != "")
                        {
                            dictionary.Add("iphone_number", row["iphone_number"].ToString());
                        }
                        else
                        {
                            dictionary.Add("iphone_number", "No Information");
                        }
                        if (row["itagline"].ToString() != "")
                        {
                            dictionary.Add("itagline", row["itagline"].ToString());
                        }
                        else
                        {
                            dictionary.Add("itagline", "No Information");
                        }
                        if (row["iwebsite"].ToString() != "")
                        {
                            dictionary.Add("iwebsite", row["iwebsite"].ToString());
                        }
                        else
                        {
                            dictionary.Add("iwebsite", "No Information");
                        }
                        if (row["ilogo_pic"].ToString() != "")
                        {
                            dictionary.Add("ilogo_pic", row["ilogo_pic"].ToString());
                        }
                        else
                        {
                            dictionary.Add("ilogo_pic", "No Information");
                        }
                        if (row["iMessage_myscreen"].ToString() != "")
                        {
                            dictionary.Add("iMessage_myscreen", row["iMessage_myscreen"].ToString());
                        }
                        else
                        {
                            dictionary.Add("iMessage_myscreen", "No Information");
                        }
                        if (row["ifacebook"].ToString() != "")
                        {
                            dictionary.Add("ifacebook", row["ifacebook"].ToString());
                        }
                        else
                        {
                            dictionary.Add("ifacebook", "No Information");
                        }
                        if (row["itwitter"].ToString() != "")
                        {
                            dictionary.Add("itwitter", row["itwitter"].ToString());
                        }
                        else
                        {
                            dictionary.Add("itwitter", "No Information");
                        }
                        if (row["idownload_version"].ToString() != "")
                        {
                            dictionary.Add("idownload_version", row["idownload_version"].ToString());
                        }
                        else
                        {
                            dictionary.Add("idownload_version", "No Information");
                        }
                        if (row["ips_country"].ToString() != "")
                        {
                            dictionary.Add("ips_country", row["ips_country"].ToString());
                        }
                        else
                        {
                            dictionary.Add("ips_country", "No Information");
                        }
                        if (row["ips_state_province"].ToString() != "")
                        {
                            dictionary.Add("ips_state_province", row["ips_state_province"].ToString());
                        }
                        else
                        {
                            dictionary.Add("ips_state_province", "No Information");
                        }
                        if (row["sponsor"].ToString() != "")
                        {
                            dictionary.Add("sponsor", row["sponsor"].ToString());
                        }
                        else
                        {
                            dictionary.Add("sponsor", "No Information");
                        }
                        if (row["sponsor_status"].ToString() != "")
                        {
                            dictionary.Add("sponsor_status", row["sponsor_status"].ToString());
                        }
                        else
                        {
                            dictionary.Add("sponsor_status", "No Information");
                        }
                    }
                    else
                    {
                        dictionary.Add("iname_line", "No Information");
                        dictionary.Add("icompany_name", "No Information");
                        dictionary.Add("iemail_address", "No Information");
                        dictionary.Add("iphone_number", "No Information");
                        dictionary.Add("itagline", "No Information");
                        dictionary.Add("iwebsite", "No Information");
                        dictionary.Add("ilogo_pic", "No Information");
                        dictionary.Add("iMessage_myscreen", "No Information");
                        dictionary.Add("idownload_version", "No Information");
                        dictionary.Add("ifacebook", "No Information");
                        dictionary.Add("itwitter", "No Information");
                        dictionary.Add("ips_country", "No Information");
                        dictionary.Add("ips_state_province", "No Information");
                        dictionary.Add("sponsor", "No Information");
                        dictionary.Add("sponsor_status", "I");
                    }
                }
                login2 = new login();
                str3 = Convert.ToString(OperationContext.Current.RequestContext.RequestMessage.Headers.To);
                login2.WebServiceName = "verifyPromoCode";
                login2.DataForService = str3;
                using (StreamReader reader2 = new StreamReader(this.WriteJson(new { status = str2, dictionary = dictionary }), Encoding.Default))
                {
                    str4 = reader2.ReadToEnd();
                }
                login2.DataRecived = str4;
                login2.webserviceListInsert();
                return this.WriteJson(new { status = str2, dictionary = dictionary });
            }
            str2 = "failed";
            dictionary = new Dictionary<string, string>();
            dictionary.Add("iname_line", "No Information");
            dictionary.Add("icompany_name", "No Information");
            dictionary.Add("iemail_address", "No Information");
            dictionary.Add("iphone_number", "No Information");
            dictionary.Add("itagline", "No Information");
            dictionary.Add("iwebsite", "No Information");
            dictionary.Add("ilogo_pic", "No Information");
            dictionary.Add("iMessage_myscreen", "No Information");
            dictionary.Add("idownload_version", "No Information");
            dictionary.Add("ifacebook", "No Information");
            dictionary.Add("itwitter", "No Information");
            dictionary.Add("ips_country", "No Information");
            dictionary.Add("ips_state_province", "No Information");
            dictionary.Add("sponsor", "No Information");
            dictionary.Add("sponsor_status", "No Information");
            login2 = new login();
            str3 = Convert.ToString(OperationContext.Current.RequestContext.RequestMessage.Headers.To);
            login2.WebServiceName = "verifyPromoCode";
            login2.DataForService = str3;
            using (StreamReader reader3 = new StreamReader(this.WriteJson(new { status = str2, dictionary = dictionary }), Encoding.Default))
            {
                str4 = reader3.ReadToEnd();
            }
            login2.DataRecived = str4;
            login2.webserviceListInsert();
            return this.WriteJson(new { status = str2, dictionary = dictionary });
        }


        #endregion

        #region[Common Function]
        private Stream WriteJson(object value)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(serializer.Serialize(value)));
            WebOperationContext.Current.OutgoingResponse.ContentType = "application/json; charset=utf-8";
            return stream;
        }
        #endregion

        #region [Android App Functions]
        //Android Functions
        public Stream getApp_Initial_Setup(Stream myfile)
        {
            #region [Split the parameters that are in the Stream and assign to variables]
            StreamReader reader = new StreamReader(myfile, true);
            string[] str_getSplitPassParameters = HttpUtility.UrlDecode(reader.ReadToEnd()).Split(new char[] { '/' });
            login login = new login();
            
            string[] strArray_getUsername = str_getSplitPassParameters[0].Split(new char[] { '=' });
            login.User_Name = strArray_getUsername[1];

            string[] strArray_getPassword = str_getSplitPassParameters[1].Split(new char[] { '=' });
            login.Password = strArray_getPassword[1];

            string[] strArray_getpromo_code = str_getSplitPassParameters[2].Split(new char[] { '=' });
            login.promocode = strArray_getpromo_code[1];

            string[] strArray_getapp_mo_alert_week = str_getSplitPassParameters[3].Split(new char[] { '=' });
            login.app_mo_alert_week = strArray_getapp_mo_alert_week[1];

            string[] strArray_getapp_mo_alert_day = str_getSplitPassParameters[4].Split(new char[] { '=' });
            login.app_mo_alert_day = strArray_getapp_mo_alert_day[1];

            string[] strArray_getapp_mo_alert_hour = str_getSplitPassParameters[5].Split(new char[] { '=' });
            login.app_mo_alert_hour = strArray_getapp_mo_alert_hour[1];

            string[] strArray_getapp_mo_alert_badge = str_getSplitPassParameters[6].Split(new char[] { '=' });
            login.app_mo_alert_badge = strArray_getapp_mo_alert_badge[1];


            string[] strArray_getapp_mo_alert_popup = str_getSplitPassParameters[7].Split(new char[] { '=' });
            login.app_mo_alert_popup = strArray_getapp_mo_alert_popup[1];

            string[] strArray_getsentFrom = str_getSplitPassParameters[8].Split(new char[] { '=' });
            login.SentFrom = strArray_getsentFrom[1];

            #endregion



            Dictionary<string, string> dictionary;
            dictionary = new Dictionary<string, string>();

            //Only Call the Webservice to Database, if it has key values(iphoneApp,androidApp) 
            if (login.SentFrom == "iphoneApp" || login.SentFrom == "androidApp")
            {
                #region[ Call the login class method and get data from store procedure,bind the data with the dictionary]
                // Call the login method and get data from store procedure
                DataTable getdatafrom_sp_Initial_Setup = login.Initial_Setupdata();


                //bind the database data with the dictionary
                if (getdatafrom_sp_Initial_Setup != null && getdatafrom_sp_Initial_Setup.Rows.Count > 0)
                {
                    foreach (DataRow row in getdatafrom_sp_Initial_Setup.Rows)
                    {

                        if (row["initialsetup"].ToString() != "")
                        {
                            dictionary.Add("initialsetup", row["InitialSetup"].ToString());
                        }
                        else
                        {
                            dictionary.Add("initialsetup", "No Information");
                        }
                        //if (row["promocodeaction"].ToString() != "")
                        //{
                        //    dictionary.Add("promocodeaction", row["PromoCodeAction"].ToString());
                        //}
                        //else
                        //{
                        //    dictionary.Add("promocodeaction", "No Information");
                        //}
                        if (row["user_id"].ToString() != "")
                        {
                            dictionary.Add("user_id", row["user_id"].ToString());
                        }
                        else
                        {
                            dictionary.Add("user_id", "No Information");
                        }
                        if (row["sponsor"].ToString() != "")
                        {
                            dictionary.Add("sponsor", row["sponsor"].ToString());
                        }
                        else
                        {
                            dictionary.Add("sponsor", "No Information");
                        }
                        if (row["welcome_image"].ToString() != "")
                        {
                            dictionary.Add("welcome_image", row["welcome_image"].ToString());
                        }
                        else
                        {
                            dictionary.Add("welcome_image", "No Information");
                        }
                        if (row["welcome_image_chg_time"].ToString() != "")
                        {
                            dictionary.Add("welcome_image_chg_time", row["welcome_image_chg_time"].ToString());
                        }
                        else
                        {
                            dictionary.Add("welcome_image_chg_time", "No Information");
                        }
                        if (row["iname_line"].ToString() != "")
                        {
                            dictionary.Add("iname_line", row["iname_line"].ToString());
                        }
                        else
                        {
                            dictionary.Add("iname_line", "No Information");
                        }
                        if (row["icompany_name"].ToString() != "")
                        {
                            dictionary.Add("icompany_name", row["icompany_name"].ToString());
                        }
                        else
                        {
                            dictionary.Add("icompany_name", "No Information");
                        }
                        if (row["iemail_address"].ToString() != "")
                        {
                            dictionary.Add("iemail_address", row["iemail_address"].ToString());
                        }
                        else
                        {
                            dictionary.Add("iemail_address", "No Information");
                        }
                        if (row["iphone_number"].ToString() != "")
                        {
                            dictionary.Add("iphone_number", row["iphone_number"].ToString());
                        }
                        else
                        {
                            dictionary.Add("iphone_number", "No Information");
                        }
                        if (row["itagline"].ToString() != "")
                        {
                            dictionary.Add("itagline", row["itagline"].ToString());
                        }
                        else
                        {
                            dictionary.Add("itagline", "No Information");
                        }
                        if (row["ilogo_pic"].ToString() != "")
                        {
                            dictionary.Add("ilogo_pic", row["ilogo_pic"].ToString());
                        }
                        else
                        {
                            dictionary.Add("ilogo_pic", "No Information");
                        }
                        if (row["iwebsite"].ToString() != "")
                        {
                            dictionary.Add("iwebsite", row["iwebsite"].ToString());
                        }
                        else
                        {
                            dictionary.Add("iwebsite", "No Information");
                        }
                        if (row["spon_change_time"].ToString() != "")
                        {
                            dictionary.Add("spon_change_time", row["spon_change_time"].ToString());
                        }
                        else
                        {
                            dictionary.Add("spon_change_time", "No Information");
                        }
                    }

                }

                #endregion
            }
            //Convert dictionary to json
            return this.WriteJson(new { dictionary = dictionary });
        }

        public Stream getApp_Reopen(Stream myfile)
        {
            #region [Split the parameters that are in the Stream and assign to variables]
            StreamReader reader = new StreamReader(myfile, true);
            string[] str_getSplitPassParameters = HttpUtility.UrlDecode(reader.ReadToEnd()).Split(new char[] { '/' });
           
            login login = new login();
            
            string[] strArray_getUserID = str_getSplitPassParameters[0].Split(new char[] { '=' });
            login.UserID = strArray_getUserID[1];

            string[] strArray_getUserName = str_getSplitPassParameters[1].Split(new char[] { '=' });
            login.User_Name = strArray_getUserName[1];

            string[] strArray_getPassword = str_getSplitPassParameters[2].Split(new char[] { '=' });
            login.Password = strArray_getPassword[1];

            string[] strArray_getpromo_code = str_getSplitPassParameters[3].Split(new char[] { '=' });
            login.promocode = strArray_getpromo_code[1];

            string[] strArray_getWelcomeImageChgTime = str_getSplitPassParameters[4].Split(new char[] { '=' });
            login.WelcomeImageChgTime = strArray_getWelcomeImageChgTime[1];

            string[] strArray_getSponsorCchangeTime = str_getSplitPassParameters[5].Split(new char[] { '=' });
            login.SponsorCchangeTime = strArray_getSponsorCchangeTime[1];
            #endregion

            #region[ Call the login class method and get data from store procedure,bind the data with the dictionary]
            // Call the login method and get data from store procedure
            DataTable getdatafrom_sp_App_Reopendata = login.App_Reopendata();
            Dictionary<string, string> dictionary;
            dictionary = new Dictionary<string, string>();

            //bind the database data with the dictionary
            if (getdatafrom_sp_App_Reopendata.Rows.Count > 0)
            {
                foreach (DataRow row in getdatafrom_sp_App_Reopendata.Rows)
                {

                    if (row["user_id"].ToString() != "")
                    {
                        dictionary.Add("user_id", row["user_id"].ToString());
                    }
                    else
                    {
                        dictionary.Add("user_id", "No Information");
                    }
                    if (row["user_name"].ToString() != "")
                    {
                        dictionary.Add("user_name", row["user_name"].ToString());
                    }
                    else
                    {
                        dictionary.Add("user_name", "No Information");
                    }
                    if (row["password"].ToString() != "")
                    {
                        dictionary.Add("password", row["password"].ToString());
                    }
                    else
                    {
                        dictionary.Add("password", "No Information");
                    }
                    if (row["sponsor"].ToString() != "")
                    {
                        dictionary.Add("sponsor", row["sponsor"].ToString());
                    }
                    else
                    {
                        dictionary.Add("sponsor", "No Information");
                    }
                   if (row["welcome_image"].ToString() != "")
                    {
                        dictionary.Add("welcome_image", row["welcome_image"].ToString());
                    }
                    else
                    {
                        dictionary.Add("welcome_image", "No Information");
                    }
                    if (row["welcome_image_chg_time"].ToString() != "")
                    {
                        dictionary.Add("welcome_image_chg_time", row["welcome_image_chg_time"].ToString());
                    }
                    else
                    {
                        dictionary.Add("welcome_image_chg_time", "No Information");
                    }
                    if (row["iname_line"].ToString() != "")
                    {
                        dictionary.Add("iname_line", row["iname_line"].ToString());
                    }
                    else
                    {
                        dictionary.Add("iname_line", "No Information");
                    }
                    
                    if (row["icompany_name"].ToString() != "")
                    {
                        dictionary.Add("icompany_name", row["icompany_name"].ToString());
                    }
                    else
                    {
                        dictionary.Add("icompany_name", "No Information");
                    }
                   
                    if (row["iemail_address"].ToString() != "")
                    {
                        dictionary.Add("iemail_address", row["iemail_address"].ToString());
                    }
                    else
                    {
                        dictionary.Add("iemail_address", "No Information");
                    }
                    if (row["iphone_number"].ToString() != "")
                    {
                        dictionary.Add("iphone_number", row["iphone_number"].ToString());
                    }
                    else
                    {
                        dictionary.Add("iphone_number", "No Information");
                    }
                   
                    if (row["itagline"].ToString() != "")
                    {
                        dictionary.Add("itagline", row["itagline"].ToString());
                    }
                    else
                    {
                        dictionary.Add("itagline", "No Information");
                    }
                    if (row["ilogo_pic"].ToString() != "")
                    {
                        dictionary.Add("ilogo_pic", row["ilogo_pic"].ToString());
                    }
                    else
                    {
                        dictionary.Add("ilogo_pic", "No Information");
                    }
                    if (row["iwebsite"].ToString() != "")
                    {
                        dictionary.Add("iwebsite", row["iwebsite"].ToString());
                    }
                    else
                    {
                        dictionary.Add("iwebsite", "No Information");
                    }
                    if (row["spon_change_time"].ToString() != "")
                    {
                        dictionary.Add("spon_change_time", row["spon_change_time"].ToString());
                    }
                    else
                    {
                        dictionary.Add("spon_change_time", "No Information");
                    }

                    if (row["SponsorDataAction"].ToString() != "")
                    {
                        dictionary.Add("sponsordataaction", row["SponsorDataAction"].ToString());
                    }
                    else
                    {
                        dictionary.Add("sponsordataaction", "No Information");
                    }

                    if (row["PromocodeAction"].ToString() != "")
                    {
                        dictionary.Add("promocodeaction", row["PromocodeAction"].ToString());
                    }
                    else
                    {
                        dictionary.Add("promocodeaction", "No Information");
                    }

                    if (row["AppLogin"].ToString() != "")
                    {
                        dictionary.Add("applogin", row["AppLogin"].ToString());
                    }
                    else
                    {
                        dictionary.Add("applogin", "No Information");
                    }

                    if (row["WelcomeImage"].ToString() != "")
                    {
                        dictionary.Add("welcomeimage", row["WelcomeImage"].ToString());
                    }
                    else
                    {
                        dictionary.Add("welcomeimage", "No Information");
                    }

                    if (row["DbStatus"].ToString() != "")
                    {
                        dictionary.Add("dbstatus", row["DbStatus"].ToString());
                    }
                    else
                    {
                        dictionary.Add("dbstatus", "No Information");
                    }

                }

            }

            #endregion

            //Convert dictionary to json
            return this.WriteJson(new { dictionary = dictionary });
        }

        #endregion

    }
}

